package cn.hrms.controller;

import cn.hrms.domain.Evaluation;
import cn.hrms.domain.web.R;
import cn.hrms.domain.web.TableDataInfo;
import cn.hrms.service.IEvaluationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 评价接口
 *
 * @author xiaokai54
 * @date 2024/12/19
 */
@RestController
@RequestMapping("/admin/evaluation")
@RequiredArgsConstructor
public class EvaluationController extends BaseController {
	private final IEvaluationService evaluationService;

	/**
	 * 查询评价列表
	 */
	@GetMapping("/list")
	public TableDataInfo list(Evaluation evaluation) {
		startPage();
		List<Evaluation> list = evaluationService.selectEvaluationList(evaluation);
		return getDataTable(list);
	}

	/**
	 * 获取评价详细信息
	 */
	@GetMapping(value = "/{evaluationId}")
	public R<Evaluation> getInfo(@PathVariable("evaluationId") Long evaluationId) {
		return R.ok(evaluationService.selectEvaluationByEvaluationId(evaluationId));
	}

	/**
	 * 新增评价
	 */
	@PostMapping
	public R<Void> add(@RequestBody Evaluation evaluation) {
		return toAjax(evaluationService.insertEvaluation(evaluation));
	}

	/**
	 * 修改评价
	 */
	@PutMapping
	public R<Void> edit(@RequestBody Evaluation evaluation) {
		return toAjax(evaluationService.updateEvaluation(evaluation));
	}

	/**
	 * 删除评价
	 */
	@DeleteMapping("/{evaluationIds}")
	public R<Void> remove(@PathVariable Long[] evaluationIds) {
		return toAjax(evaluationService.deleteEvaluationByEvaluationIds(evaluationIds));
	}
}
